<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>linux简单命令 | Threadv</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="linux简单命令 ls [选项] [目录名 | 列出相关目录下的所有目录和文件 1234567891011121314-a  列出包括.a开头的隐藏文件的所有文件-A  通-a，但不列出&quot;.&quot;和&quot;..&quot;-l  列出文件的详细信息-c  根据ctime排序显示-t  根据文件修改">
<meta name="keywords" content="linux">
<meta property="og:type" content="article">
<meta property="og:title" content="linux简单命令">
<meta property="og:url" content="http://yoursite.com/2018/05/31/linux/linux简单命令/index.html">
<meta property="og:site_name" content="Threadv">
<meta property="og:description" content="linux简单命令 ls [选项] [目录名 | 列出相关目录下的所有目录和文件 1234567891011121314-a  列出包括.a开头的隐藏文件的所有文件-A  通-a，但不列出&quot;.&quot;和&quot;..&quot;-l  列出文件的详细信息-c  根据ctime排序显示-t  根据文件修改时间排序---color[=WHEN] 用色彩辨别文件类型 WHEN 可以是&apos;never&apos;、&apos;always&apos;或&apos;auto">
<meta property="og:updated_time" content="2020-03-29T11:01:38.418Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="linux简单命令">
<meta name="twitter:description" content="linux简单命令 ls [选项] [目录名 | 列出相关目录下的所有目录和文件 1234567891011121314-a  列出包括.a开头的隐藏文件的所有文件-A  通-a，但不列出&quot;.&quot;和&quot;..&quot;-l  列出文件的详细信息-c  根据ctime排序显示-t  根据文件修改时间排序---color[=WHEN] 用色彩辨别文件类型 WHEN 可以是&apos;never&apos;、&apos;always&apos;或&apos;auto">
  
    <link rel="alternate" href="/atom.xml" title="Threadv" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Threadv</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Suche"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-linux/linux简单命令" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/05/31/linux/linux简单命令/" class="article-date">
  <time datetime="2018-05-31T07:09:11.000Z" itemprop="datePublished">2018-05-31</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      linux简单命令
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h5 id="linux简单命令"><a href="#linux简单命令" class="headerlink" title="linux简单命令"></a>linux简单命令</h5><ol>
<li><p>ls [选项] [目录名 | 列出相关目录下的所有目录和文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">-a  列出包括.a开头的隐藏文件的所有文件</span><br><span class="line">-A  通-a，但不列出"."和".."</span><br><span class="line">-l  列出文件的详细信息</span><br><span class="line">-c  根据ctime排序显示</span><br><span class="line">-t  根据文件修改时间排序</span><br><span class="line">---color[=WHEN] 用色彩辨别文件类型 WHEN 可以是'never'、'always'或'auto'其中之一</span><br><span class="line">   白色：表示普通文件</span><br><span class="line">   蓝色：表示目录</span><br><span class="line">   绿色：表示可执行文件</span><br><span class="line">   红色：表示压缩文件</span><br><span class="line">   浅蓝色：链接文件</span><br><span class="line">   红色闪烁：表示链接的文件有问题</span><br><span class="line">   黄色：表示设备文件</span><br><span class="line">   灰色：表示其它文件</span><br></pre></td></tr></table></figure>
</li>
<li><p>mv [选项] 源文件或目录 目录或多个源文件 | 移动或重命名文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">-b  覆盖前做备份</span><br><span class="line">-f  如存在不询问而强制覆盖</span><br><span class="line">-i  如存在则询问是否覆盖</span><br><span class="line">-u  较新才覆盖</span><br><span class="line">-t  将多个源文件移动到统一目录下，目录参数在前，文件参数在后</span><br><span class="line">eg:</span><br><span class="line">   mv a /tmp/ 将文件a移动到 /tmp目录下</span><br><span class="line">   mv a b 将a命名为b</span><br><span class="line">   mv /home/zenghao test1.txt test2.txt test3.txt</span><br></pre></td></tr></table></figure>
</li>
<li><p>cp [选项] 源文件或目录 目录或多个源文件 | 将源文件复制至目标文件，或将多个源文件复制至目标目录。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">-r -R 递归复制该目录及其子目录内容</span><br><span class="line">-p  连同档案属性一起复制过去</span><br><span class="line">-f  不询问而强制复制</span><br><span class="line">-s  生成快捷方式</span><br><span class="line">-a  将档案的所有特性都一起复制</span><br></pre></td></tr></table></figure>
</li>
<li><p>scp [参数] [原路径] [目标路径] | 在Linux服务器之间复制文件和目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">-v  详细显示输出的具体情况</span><br><span class="line">-r  递归复制整个目录</span><br><span class="line">(1) 复制文件：  </span><br><span class="line">命令格式：  </span><br><span class="line">scp local_file remote_username@remote_ip:remote_folder  </span><br><span class="line">或者  </span><br><span class="line">scp local_file remote_username@remote_ip:remote_file  </span><br><span class="line">或者  </span><br><span class="line">scp local_file remote_ip:remote_folder  </span><br><span class="line">或者  </span><br><span class="line">scp local_file remote_ip:remote_file  </span><br><span class="line">第1,2个指定了用户名，命令执行后需要输入用户密码，第1个仅指定了远程的目录，文件名字不变，第2个指定了文件名  </span><br><span class="line">第3,4个没有指定用户名，命令执行后需要输入用户名和密码，第3个仅指定了远程的目录，文件名字不变，第4个指定了文件名   </span><br><span class="line">(2) 复制目录：  </span><br><span class="line">命令格式：  </span><br><span class="line">scp -r local_folder remote_username@remote_ip:remote_folder  </span><br><span class="line">或者  </span><br><span class="line">scp -r local_folder remote_ip:remote_folder  </span><br><span class="line">第1个指定了用户名，命令执行后需要输入用户密码；  </span><br><span class="line">第2个没有指定用户名，命令执行后需要输入用户名和密码；</span><br><span class="line">eg:</span><br><span class="line">   从 本地 复制到 远程</span><br><span class="line">   scp /home/daisy/full.tar.gz root@172.19.2.75:/home/root </span><br><span class="line">   从 远程 复制到 本地</span><br><span class="line">   scp root@/172.19.2.75:/home/root/full.tar.gz /home/daisy/full.tar.gz</span><br></pre></td></tr></table></figure>
</li>
<li><p>rm [选项] 文件 | 删除文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-r  删除文件夹</span><br><span class="line">-f  删除不提示</span><br><span class="line">-i  删除提示</span><br><span class="line">-v  详细显示进行步骤</span><br></pre></td></tr></table></figure>
</li>
<li><p>touch [选项] 文件 | 创建空文件或更新文件时间</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-a  只修改存取时间</span><br><span class="line">-m  值修改变动时间</span><br><span class="line">-r  eg:touch -r a b ,使b的时间和a相同</span><br><span class="line">-t  指定特定的时间 eg:touch -t 201211142234.50 log.log </span><br><span class="line">   -t time [[CC]YY]MMDDhhmm[.SS],C:年前两位</span><br></pre></td></tr></table></figure>
</li>
<li><p>pwd 查看当前所在路径</p>
</li>
<li><p>cd 改变当前目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">- ：返回上层目录</span><br><span class="line">.. :返回上层目录</span><br><span class="line">回车  ：返回主目录</span><br><span class="line">/   :根目录</span><br></pre></td></tr></table></figure>
</li>
<li><p>mkdir [选项] 目录… | 创建新目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-p  递归创建目录，若父目录不存在则依次创建</span><br><span class="line">-m  自定义创建目录的权限  eg:mkdir -m 777 hehe</span><br><span class="line">-v  显示创建目录的详细信息</span><br></pre></td></tr></table></figure>
</li>
<li><p>rmdir 删除空目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-v  显示执行过程</span><br><span class="line">-p  若自父母删除后父目录为空则一并删除</span><br></pre></td></tr></table></figure>
</li>
<li><p>rm [选项] 文件… | 一个或多个文件或目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-f  忽略不存在的文件，不给出提示</span><br><span class="line">-i  交互式删除</span><br><span class="line">-r  将列出的目录及其子目录递归删除</span><br><span class="line">-v  列出详细信息</span><br></pre></td></tr></table></figure>
</li>
<li><p>echo：显示内容</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-n  输出后不换行</span><br><span class="line">-e  遇到转义字符特殊处理  </span><br><span class="line">   eg:</span><br><span class="line">       echo "he\nhe"   显示he\nhe</span><br><span class="line">       ehco -e "he\nhe"    显示he(换行了)he</span><br></pre></td></tr></table></figure>
</li>
<li><p>cat [选项] [文件]..| 一次显示整个文件或从键盘创建一个文件或将几个文件合并成一个文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">-n  编号文件内容再输出</span><br><span class="line">-E  在结束行提示$</span><br></pre></td></tr></table></figure>
</li>
<li><p>tac | 反向显示</p>
</li>
<li><p>more | 按页查看文章内容，从前向后读取文件，因此在启动时就加载整个文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">+n  从第n行开始显示</span><br><span class="line">-n  每次查看n行数据</span><br><span class="line">+/String    搜寻String字符串位置，从其前两行开始查看</span><br><span class="line">-c  清屏再显示</span><br><span class="line">-p  换页时清屏</span><br></pre></td></tr></table></figure>
</li>
<li><p>less | 可前后移动地逐屏查看文章内容，在查看前不会加载整个文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">-m  显示类似于more命令的百分比</span><br><span class="line">-N  显示行号</span><br><span class="line">/   字符串：向下搜索“字符串”的功能</span><br><span class="line">?   字符串：向上搜索“字符串”的功能</span><br><span class="line">n   重复前一个搜索（与 / 或 ? 有关）</span><br><span class="line">N   反向重复前一个搜索（与 / 或 ? 有关）</span><br><span class="line">b   向后翻一页</span><br><span class="line">d   向后翻半页</span><br></pre></td></tr></table></figure>
</li>
<li><p>nl [选项]… [文件]… | 将输出内容自动加上行号 </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-b </span><br><span class="line">-b a 不论是否有空行，都列出行号（类似 cat -n) </span><br><span class="line">-b t 空行则不列行号（默认） </span><br><span class="line">-n 有ln rn rz三个参数，分别为再最左方显示，最右方显示不加0，最右方显示加0</span><br></pre></td></tr></table></figure>
</li>
<li><p>head [参数]… [文件]… | 显示档案开头，默认开头10行</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-v  显示文件名</span><br><span class="line">-c number   显示前number个字符,若number为负数,则显示除最后number个字符的所有内容</span><br><span class="line">-number/n (+)number     显示前number行内容，</span><br><span class="line">-n number   若number为负数，则显示除最后number行数据的所有内容</span><br></pre></td></tr></table></figure>
</li>
<li><p>tail [必要参数] [选择参数] [文件] | 显示文件结尾内容</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-v  显示详细的处理信息</span><br><span class="line">-q  不显示处理信息</span><br><span class="line">-num/-n (-)num      显示最后num行内容</span><br><span class="line">-n +num 从第num行开始显示后面的数据</span><br><span class="line">-c  显示最后c个字符</span><br><span class="line">-f  循环读取</span><br></pre></td></tr></table></figure>
</li>
<li><p>vi 编辑文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">:w filename 将文章以指定的文件名保存起来  </span><br><span class="line">:wq 保存并退出</span><br><span class="line">:q! 不保存而强制退出</span><br><span class="line">命令行模式功能键</span><br><span class="line">1）插入模式</span><br><span class="line">   按「i」切换进入插入模式「insert mode」，按"i"进入插入模式后是从光标当前位置开始输入文件；</span><br><span class="line">   按「a」进入插入模式后，是从目前光标所在位置的下一个位置开始输入文字；</span><br><span class="line">   按「o」进入插入模式后，是插入新的一行，从行首开始输入文字。</span><br><span class="line"></span><br><span class="line">2）从插入模式切换为命令行模式</span><br><span class="line"> 按「ESC」键。</span><br><span class="line">3）移动光标</span><br><span class="line">　　vi可以直接用键盘上的光标来上下左右移动，但正规的vi是用小写英文字母「h」、「j」、「k」、「l」，分别控制光标左、下、上、右移一格。</span><br><span class="line">　　按「ctrl」+「b」：屏幕往"后"移动一页。</span><br><span class="line">　　按「ctrl」+「f」：屏幕往"前"移动一页。</span><br><span class="line">　　按「ctrl」+「u」：屏幕往"后"移动半页。</span><br><span class="line">　　按「ctrl」+「d」：屏幕往"前"移动半页。</span><br><span class="line">　　按数字「0」：移到文章的开头。</span><br><span class="line">　　按「G」：移动到文章的最后。</span><br><span class="line">　　按「$」：移动到光标所在行的"行尾"。</span><br><span class="line">　　按「^」：移动到光标所在行的"行首"</span><br><span class="line">　　按「w」：光标跳到下个字的开头</span><br><span class="line">　　按「e」：光标跳到下个字的字尾</span><br><span class="line">　　按「b」：光标回到上个字的开头</span><br><span class="line">　　按「#l」：光标移到该行的第#个位置，如：5l,56l。</span><br><span class="line"></span><br><span class="line">4）删除文字</span><br><span class="line">　　「x」：每按一次，删除光标所在位置的"后面"一个字符。</span><br><span class="line">　　「#x」：例如，「6x」表示删除光标所在位置的"后面"6个字符。</span><br><span class="line">　　「X」：大写的X，每按一次，删除光标所在位置的"前面"一个字符。</span><br><span class="line">　　「#X」：例如，「20X」表示删除光标所在位置的"前面"20个字符。</span><br><span class="line">　　「dd」：删除光标所在行。</span><br><span class="line">　　「#dd」：从光标所在行开始删除#行</span><br><span class="line"></span><br><span class="line">5）复制</span><br><span class="line">　　「yw」：将光标所在之处到字尾的字符复制到缓冲区中。</span><br><span class="line">　　「#yw」：复制#个字到缓冲区</span><br><span class="line">　　「yy」：复制光标所在行到缓冲区。</span><br><span class="line">　　「#yy」：例如，「6yy」表示拷贝从光标所在的该行"往下数"6行文字。</span><br><span class="line">　　「p」：将缓冲区内的字符贴到光标所在位置。注意：所有与"y"有关的复制命令都必须与"p"配合才能完成复制与粘贴功能。</span><br><span class="line"></span><br><span class="line">6）替换</span><br><span class="line">　　「r」：替换光标所在处的字符。</span><br><span class="line">　　「R」：替换光标所到之处的字符，直到按下「ESC」键为止。</span><br><span class="line"></span><br><span class="line">7）回复上一次操作</span><br><span class="line">　　「u」：如果您误执行一个命令，可以马上按下「u」，回到上一个操作。按多次"u"可以执行多次回复。</span><br><span class="line"></span><br><span class="line">8）更改</span><br><span class="line">　　「cw」：更改光标所在处的字到字尾处</span><br><span class="line">　　「c#w」：例如，「c3w」表示更改3个字</span><br><span class="line"></span><br><span class="line">9）跳至指定的行</span><br><span class="line">　　「ctrl」+「g」列出光标所在行的行号。</span><br><span class="line">　　「#G」：例如，「15G」，表示移动光标至文章的第15行行首。</span><br></pre></td></tr></table></figure>
</li>
<li><p>which 可执行文件名称 | 查看可执行文件的位置，在PATH变量指定的路径中查看系统命令是否存在及其位置</p>
</li>
<li><p>whereis [-bmsu] [BMS 目录名 -f ] 文件名| 定位可执行文件、源代码文件、帮助文件在文件系统中的位置</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">-b   定位可执行文件。</span><br><span class="line">-m   定位帮助文件。</span><br><span class="line">-s   定位源代码文件。</span><br><span class="line">-u   搜索默认路径下除可执行文件、源代码文件、帮助文件以外的其它文件。</span><br><span class="line">-B   指定搜索可执行文件的路径。</span><br><span class="line">-M   指定搜索帮助文件的路径。</span><br><span class="line">-S   指定搜索源代码文件的路径。</span><br></pre></td></tr></table></figure>
</li>
<li><p>locate | 通过搜寻数据库快速搜寻档案</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-r  使用正规运算式做寻找的条件</span><br></pre></td></tr></table></figure>
</li>
<li><p>find find [PATH] [option] [action] | 在文件树种查找文件，并作出相应的处理</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">选项与参数：</span><br><span class="line">1. 与时间有关的选项：共有 -atime, -ctime 与 -mtime 和-amin,-cmin与-mmin，以 -mtime 说明</span><br><span class="line">   -mtime n ：n 为数字，意义为在 n 天之前的『一天之内』被更动过内容的档案；</span><br><span class="line">   -mtime +n ：列出在 n 天之前(不含 n 天本身)被更动过内容的档案档名；</span><br><span class="line">   -mtime -n ：列出在 n 天之内(含 n 天本身)被更动过内容的档案档名。</span><br><span class="line">   -newer file ：file 为一个存在的档案，列出比 file 还要新的档案档名</span><br><span class="line"></span><br><span class="line">2. 与使用者或组名有关的参数：</span><br><span class="line">   -uid n ：n 为数字，这个数字是用户的账号 ID，亦即 UID</span><br><span class="line">   -gid n ：n 为数字，这个数字是组名的 ID，亦即 GID</span><br><span class="line">   -user name ：name 为使用者账号名称！例如 dmtsai</span><br><span class="line">   -group name：name 为组名，例如 users ；</span><br><span class="line">   -nouser ：寻找档案的拥有者不存在 /etc/passwd 的人！</span><br><span class="line">   -nogroup ：寻找档案的拥有群组不存在于 /etc/group 的档案！</span><br><span class="line"></span><br><span class="line">3. 与档案权限及名称有关的参数：</span><br><span class="line">   -name filename：搜寻文件名为 filename 的档案（可使用通配符）</span><br><span class="line">   -size [+-]SIZE：搜寻比 SIZE 还要大(+)或小(-)的档案。这个 SIZE 的规格有：</span><br><span class="line">       c: 代表 byte</span><br><span class="line">       k: 代表 1024bytes。所以，要找比 50KB还要大的档案，就是『 -size +50k 』</span><br><span class="line">   -type TYPE ：搜寻档案的类型为 TYPE 的，类型主要有：</span><br><span class="line">       一般正规档案 (f)</span><br><span class="line">       装置档案 (b, c)</span><br><span class="line">       目录 (d)</span><br><span class="line">       连结档 (l)</span><br><span class="line">       socket (s)</span><br><span class="line">       FIFO (p)</span><br><span class="line">   -perm mode ：搜寻档案权限『刚好等于』 mode的档案，这个mode为类似chmod的属性值，举例来说，-rwsr-xr-x 的属性为4755！</span><br><span class="line">   -perm -mode ：搜寻档案权限『必须要全部囊括 mode 的权限』的档案，举例来说，</span><br><span class="line">       我们要搜寻-rwxr--r-- 亦即 0744 的档案，使用-perm -0744，当一个档案的权限为 -rwsr-xr-x ，亦即 4755 时，也会被列出来，因为 -rwsr-xr-x 的属性已经囊括了 -rwxr--r-- 的属性了。</span><br><span class="line">   -perm +mode ：搜寻档案权限『包含任一 mode 的权限』的档案，举例来</span><br><span class="line">       说，我们搜寻-rwxr-xr-x ，亦即 -perm +755 时，但一个文件属性为 -rw-------也会被列出来，因为他有 -rw.... 的属性存在！</span><br><span class="line">4. 额外可进行的动作：</span><br><span class="line">   -exec command ：command 为其他指令，-exec 后面可再接额外的指令来处理搜寻到的结果。</span><br><span class="line">   -print ：将结果打印到屏幕上，这个动作是预设动作！</span><br><span class="line">   eg:</span><br><span class="line">       find / -perm +7000 -exec ls -l &#123;&#125; \; ,额外指令以-exec开头，以\;结尾&#123;&#125;代替前面找到的内容</span><br><span class="line">   | xargs </span><br><span class="line">       -i  默认的前面输出用&#123;&#125;代替 </span><br><span class="line">       eg:</span><br><span class="line">           find . -name "*.log" | xargs -i mv &#123;&#125; test4</span><br></pre></td></tr></table></figure>
</li>
<li><p>grep ‘正则表达式’ 文件名 | 用正则表达式搜索文本，并把匹配的行打印出来</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-c  只输出匹配行的计数。</span><br><span class="line">-I  不区分大小写(只适用于单字符)。</span><br><span class="line">-l  只显示文件名</span><br><span class="line">-v  显示不包含匹配文本的所有行。</span><br><span class="line">-n  显示匹配行数据及其行号</span><br></pre></td></tr></table></figure>
</li>
<li><p>gzip [-cdtv#] 檔名 | 压缩、解压缩，源文件都不再存在</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-d  进行解压缩</span><br><span class="line">-c  将压缩的数据输出到屏幕上</span><br><span class="line">-v  :显示原档案/压缩文件案的压缩比等信息</span><br><span class="line"><span class="meta">-#</span><span class="bash">  ：压缩等级，-1最快，但压缩比最差，=9最慢，但压缩比最好</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>gunzip | 解压缩</p>
</li>
<li><p>bzip2 | 压缩、解压缩</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-d  :解压</span><br><span class="line">-z  :压缩</span><br><span class="line">-k  :保留源文件</span><br><span class="line">-c ：将压缩的过程产生的数据输出到屏幕上！</span><br><span class="line">-v ：可以显示出原档案/压缩文件案的压缩比等信息；</span><br><span class="line"><span class="meta">-#</span><span class="bash"> ：与 gzip 同样的，都是在计算压缩比的参数， -9 最佳， -1 最快！</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>bzcat 读取数据而无需解压</p>
</li>
<li>tar [主选项+辅选项] 文件或者目录 | 多个目录或档案打包、压缩成一个大档案</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">主选项：</span><br><span class="line">   -c  建立打包档案，可搭配 -v 来察看过程中被打包的档名(filename)</span><br><span class="line">   -t  察看打包档案的内容含有哪些档名，重点在察看『档名』就是了；</span><br><span class="line">   -x  解打包或解压缩的功能，可以搭配 -C (大写) 在特定目录解开</span><br><span class="line">辅选项：</span><br><span class="line">   -j  透过 bzip2 的支持进行压缩/解压缩：此时档名最好为 *.tar.bz2</span><br><span class="line">   -z  透过 gzip 的支持进行压缩/解压缩：此时档名最好为 *.tar.gz</span><br><span class="line">   -v  在压缩/解压缩的过程中，将正在处理的文件名显示出来！</span><br><span class="line">   -f filename -f 后面要立刻接要被处理的档名！</span><br><span class="line">   -C 目录   这个选项用在解压缩，若要在特定目录解压缩，可以使用这个选项。</span><br><span class="line">   --exclude FILE：在压缩打包过程中忽略某文件 eg: tar --exclude /home/zenghao -zcvf myfile.tar.gz /home/* /etc</span><br><span class="line">   -p  保留备份数据的原本权限与属性，常用于备份(-c)重要的配置文件</span><br><span class="line">   -P(大写）  保留绝对路径，亦即允许备份数据中含有根目录存在之意；</span><br><span class="line">eg:</span><br><span class="line">   压 缩：tar -jcvf filename.tar.bz2 要被压缩的档案或目录名称</span><br><span class="line">   查 询：tar -jtvf filename.tar.bz2</span><br><span class="line">   解压缩：tar -jxvf filename.tar.bz2 -C 欲解压缩的目录</span><br></pre></td></tr></table></figure>
<ol>
<li>exit 退出当前shell </li>
<li>logout 退出登录shell </li>
<li>shutdown -h now</li>
<li>users 显示当前登录系统地用户</li>
<li><p>who 登录在本机的用户与来源</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-H或--heading 　显示各栏位的标题信息列。</span><br></pre></td></tr></table></figure>
</li>
<li><p>w 登录在本机的用户及其运行的程序</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-s 　使用简洁格式列表，不显示用户登入时间，终端机阶段作业和程序所耗费的CPU时间。</span><br><span class="line">-h 　不显示各栏位的标题信息列。</span><br></pre></td></tr></table></figure>
</li>
<li><p>write 给当前联机的用户发消息</p>
</li>
<li>wall 给所有登录再本机的用户发消息</li>
<li>last 查看用户的登陆日志</li>
<li>lastlog 查看每个用户最后的登陆时间</li>
<li><p>finger [选项] [使用者] [用户@主机] | 查看用户信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-s 显示用户的注册名、实际姓名、终端名称、写状态、停滞时间、登录时间等信息</span><br><span class="line">-l 除了用-s选项显示的信息外，还显示用户主目录、登录shell、邮件状态等信息，以及用户主目录下的.plan、.project和.forward文件的内容。</span><br><span class="line">-p 除了不显示.plan文件和.project文件以外，与-l选项相同</span><br></pre></td></tr></table></figure>
</li>
<li><p>hostname 查看主机名</p>
</li>
<li>alias ii = “ls -l” | 添加别名</li>
<li>unalias ii | 清除别名</li>
<li><p>useradd [-u UID] [-g 初始群组] [-G 次要群组] [-c 说明栏] [-d 家目录绝对路径] [-s shell] 使用者账号名 | 新增用户</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-M  不建立用户家目录！(系统账号默认值)</span><br><span class="line">-m  建立用户家目录！(一般账号默认值)</span><br><span class="line">-r  建立一个系统的账号，这个账号的 UID 会有限制 </span><br><span class="line">-e  账号失效日期，格式为『YYYY-MM-DD』</span><br><span class="line">-D  查看useradd的各项默认值</span><br></pre></td></tr></table></figure>
</li>
<li><p>passwd | 修改密码</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">-l  使密码失效</span><br><span class="line">-u  与-l相对，用户解锁</span><br><span class="line">-S  列出登陆用户passwd文件内的相关参数</span><br><span class="line">-n  后面接天数，shadow 的第 4 字段，多久不可修改密码天数</span><br><span class="line">-x  后面接天数，shadow 的第 5 字段，多久内必须要更动密码</span><br><span class="line">-w  后面接天数，shadow 的第 6 字段，密码过期前的警告天数</span><br><span class="line">-i  后面接『日期』，shadow 的第 7 字段，密码失效日期</span><br><span class="line">使用管道刘设置密码：echo "zeng" | passwd --stdin zenghao</span><br></pre></td></tr></table></figure>
</li>
<li><p>userdel 删除用户</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-r  用户文件一并删除</span><br></pre></td></tr></table></figure>
</li>
<li><p>chage [-ldEImMW] 账号名 | 修改用户密码的相关属性</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">-l  列出该账号的详细密码参数；</span><br><span class="line">-d  后面接日期，修改 shadow 第三字段(最近一次更改密码的日期)，格式YYYY-MM-DD</span><br><span class="line">-E  后面接日期，修改 shadow 第八字段(账号失效日)，格式 YYYY-MM-DD</span><br><span class="line">-I  后面接天数，修改 shadow 第七字段(密码失效日期)</span><br><span class="line">-m  后面接天数，修改 shadow 第四字段(密码最短保留天数)</span><br><span class="line">-M  后面接天数，修改 shadow 第五字段(密码多久需要进行变更)</span><br><span class="line">-W  后面接天数，修改 shadow 第六字段(密码过期前警告日期)</span><br></pre></td></tr></table></figure>
</li>
<li><p>usermod [-cdegGlsuLU] username | 修改用户的相关属性</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">-c  后面接账号的说明，即 /etc/passwd 第五栏的说明栏，可以加入一些账号的说明。</span><br><span class="line">-d  后面接账号的家目录，即修改 /etc/passwd 的第六栏；</span><br><span class="line">-e  后面接日期，格式是 YYYY-MM-DD 也就是在 /etc/shadow 内的第八个字段数据啦！</span><br><span class="line">-f  后面接天数为 shadow 的第七字段。</span><br><span class="line">-g  后面接初始群组，修改 /etc/passwd 的第四个字段，亦即是GID的字段！</span><br><span class="line">-G  后面接次要群组，修改这个使用者能够支持的群组</span><br><span class="line">-l  后面接账号名称。亦即是修改账号名称， /etc/passwd 的第一栏！</span><br><span class="line">-s  后面接 Shell 的实际档案，例如 /bin/bash 或 /bin/csh 等等。</span><br><span class="line">-u  后面接 UID 数字啦！即 /etc/passwd 第三栏的资料；</span><br><span class="line">-L  冻结密码</span><br><span class="line">-U  解冻密码</span><br></pre></td></tr></table></figure>
</li>
<li><p>id [username] | 查看用户相关的id信息，还可以用来判断用户是否存在</p>
</li>
<li>groups 查看登陆用户支持的群组， 第一个输出的群组为有效群组</li>
<li>newgrp 切换有效群组</li>
<li><p>groupadd [-g gid] 组名 | 添加组</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-g  设定添加组的特定组id</span><br></pre></td></tr></table></figure>
</li>
<li><p>groupmod [-g gid] [-n group_name] 群组名 | 修改组信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-g  修改既有的 GID 数字</span><br><span class="line">-n  修改既有的组名</span><br></pre></td></tr></table></figure>
</li>
<li><p>groupdel [groupname] | 删除群组</p>
</li>
<li><p>gpasswd | 群组管理员功能</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">root管理员动作：</span><br><span class="line">   -gpasswd groupname 设定密码</span><br><span class="line">   -gpasswd [-A user1,...] [-M user3,...] groupname</span><br><span class="line">       -A  将 groupname 的主控权交由后面的使用者管理(该群组的管理员)</span><br><span class="line">       -M  将某些账号加入这个群组当中</span><br><span class="line">   -gpasswd [-r] groupname</span><br><span class="line">       -r  将 groupname 的密码移除</span><br><span class="line">群组管理员动作：</span><br><span class="line">   - gpasswd [-ad] user groupname </span><br><span class="line">       -a  将某位使用者加入到 groupname 这个群组当中</span><br><span class="line">       -d  将某位使用者移除出 groupname 这个群组当中</span><br></pre></td></tr></table></figure>
</li>
<li><p>chfn修改个人信息</p>
</li>
<li><p>mount [-t vfstype] [-o options] device dir</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">    -ro 采用只读方式挂接设备</span><br><span class="line">    -rw 采用读写方式挂接设备</span><br><span class="line">    eg:mount /home/mydisk.iso /tmp/mnt 通过mnt访问mydisk内的内容</span><br><span class="line">``` </span><br><span class="line">59. umount 取消挂载</span><br><span class="line">60. cut</span><br><span class="line">```shell</span><br><span class="line">    -b ：以字节为单位进行分割。这些字节位置将忽略多字节字符边界，除非也指定了 -n 标志。</span><br><span class="line">    -c ：以字符为单位进行分割。</span><br><span class="line">    -d ：自定义分隔符，默认为制表符。</span><br><span class="line">    -f  ：与-d一起使用，指定显示哪个区域。</span><br></pre></td></tr></table></figure>
</li>
<li><p>sort</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-n   依照数值的大小排序。</span><br><span class="line">-o&lt;输出文件&gt;   将排序后的结果存入指定的文件。</span><br><span class="line">-r   以相反的顺序来排序。</span><br><span class="line">-t&lt;分隔字符&gt;   指定排序时所用的栏位分隔字符。</span><br><span class="line">-k  选择以哪个区间进行排序。</span><br></pre></td></tr></table></figure>
</li>
<li><p>wc 统计指定文件中的字节数、字数、行数, 并将统计结果显示输出</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-l filename 报告行数</span><br><span class="line">-c filename 报告字节数</span><br><span class="line">-m filename 报告字符数</span><br><span class="line">-w filename 报告单词数</span><br></pre></td></tr></table></figure>
</li>
<li><p>uniq 去除文件中相邻的重复行</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-c或——count：在每列旁边显示该行重复出现的次数；</span><br><span class="line">-d或--repeated：仅显示重复出现的行列；</span><br><span class="line">-f&lt;栏位&gt;或--skip-fields=&lt;栏位&gt;：忽略比较指定的栏位；</span><br><span class="line">-s&lt;字符位置&gt;或--skip-chars=&lt;字符位置&gt;：忽略比较指定的字符；</span><br><span class="line">-u或——unique：仅显示出一次的行列；</span><br><span class="line">-w&lt;字符位置&gt;或--check-chars=&lt;字符位置&gt;：指定要比较的字符。</span><br></pre></td></tr></table></figure>
</li>
<li><p>set 显示环境变量和普通变量 </p>
</li>
<li>env 显示环境变量 </li>
<li>export 把普通变量变成环境变量 </li>
<li><p>unset 删除一个环境变量</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">aaa()&#123;&#125; 定义函数</span><br></pre></td></tr></table></figure>
</li>
<li><p>read</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-p  接提示字符</span><br><span class="line">-t  接等待的秒数</span><br></pre></td></tr></table></figure>
</li>
<li><p>declare、typeset</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-i 声明为整数</span><br><span class="line">-a 声明为数组</span><br><span class="line">-f 声明为函数</span><br><span class="line">-r 声明为只读</span><br></pre></td></tr></table></figure>
</li>
<li><p>ulimit 限制使用者的某些系统资源</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-f  此 shell 可以建立的最大档案容量 (一般可能设定为 2GB)单位为 Kbytes eg: ulimit -f 1024 限制使用者仅能建立 1MBytes 以下的容量的档案</span><br></pre></td></tr></table></figure>
</li>
<li><p>df [选项] [文件] | 显示指定磁盘文件的可用空间,如果没有文件名被指定，则所有当前被挂载的文件系统的可用空间将被显示</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">   </span><br><span class="line">-a  显示全部文件系统</span><br><span class="line">-h  文件大小友好显示</span><br><span class="line">-l  只显示本地文件系统</span><br><span class="line">-i  显示inode信息</span><br><span class="line">-T  显示文件系统类型</span><br></pre></td></tr></table></figure>
</li>
<li><p>du [选项] [文件] | 显示每个文件和目录的磁盘使用空间</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-h  方便阅读的方式</span><br><span class="line">-s  只显示总和的大小</span><br></pre></td></tr></table></figure>
</li>
<li><p>ln [参数] [源文件或目录] [目标文件或目录] | 某一个文件在另外一个位置建立一个同步的链接</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">-s  建立软连接   </span><br><span class="line">-v  显示详细的处理过程</span><br></pre></td></tr></table></figure>
</li>
<li><p>diff [参数] [文件1或目录1] [文件2或目录2] | 比较单个文件或者目录内容</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-b 　不检查空格字符的不同。</span><br><span class="line">-B 　不检查空白行。</span><br><span class="line">-i  不检查大小写</span><br><span class="line">-q  仅显示差异而不显示详细信息</span><br><span class="line">eg: diff a b &gt; parch.log 比较两个文件的不同并产生补丁</span><br></pre></td></tr></table></figure>
</li>
<li><p>date [参数]… [+格式] | 显示或设定系统的日期与时间</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">%</span><span class="bash">H 小时(以00-23来表示)。 </span></span><br><span class="line"><span class="meta">%</span><span class="bash">M 分钟(以00-59来表示)。 </span></span><br><span class="line"><span class="meta">%</span><span class="bash">P AM或PM。</span></span><br><span class="line"><span class="meta">%</span><span class="bash">D 日期(含年月日)</span></span><br><span class="line"><span class="meta">%</span><span class="bash">U 该年中的周数。</span></span><br><span class="line">date -s “2015-10-17 01:01:01″ //时间设定</span><br><span class="line">date +%Y%m%d         //显示前天年月日</span><br><span class="line">date +%Y%m%d --date="+1 day/month/year"  //显示前一天/月/年的日期</span><br><span class="line">date +%Y%m%d --date="-1 day/month/year"  //显示后一天/月/年的日期</span><br><span class="line">date -d '2 weeks' 2周后的日期</span><br></pre></td></tr></table></figure>
</li>
<li><p>cal [参数] 月份] [年份] | 查看日历</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-1  显示当月的月历</span><br><span class="line">-3  显示前、当、后一个月的日历</span><br><span class="line">-m  显示星期一为一个星期的第一天</span><br><span class="line">-s  （默认）星期天为第一天</span><br><span class="line">-j  显示当月是一年中的第几天的日历</span><br><span class="line">-y  显示当前年份的日历</span><br></pre></td></tr></table></figure>
</li>
<li><p>ps | 列出当前进程的快照</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">a   显示所有的进程</span><br><span class="line">-a  显示同一终端下的所有程序</span><br><span class="line">e   显示环境变量</span><br><span class="line">f   显示进程间的关系</span><br><span class="line">-H  显示树状结构</span><br><span class="line">r   显示当前终端的程序</span><br><span class="line">T   显示当前终端的所有程序</span><br><span class="line">-au 显示更详细的信息</span><br><span class="line">-aux    显示所有包含其他使用者的行程 </span><br><span class="line">-u  指定用户的所有进程</span><br></pre></td></tr></table></figure>
</li>
<li><p>top [参数] | 显示当前系统正在执行的进程的相关信息，包括进程ID、内存占用率、CPU占用率等</p>
</li>
<li>kill [参数] [进程号] | 杀死进程</li>
<li>free [参数] | 显示linux系统中空闲的、已用的物理内存及swap内存,及被内核使用的buffer</li>
<li>vmstat | 对操作系统的虚拟内存、进程、CPU活动进行监控</li>
<li><p>iostat [参数] [时间t] [次数n](每隔t时间刷新一次，最多刷新n次）| 对系统的磁盘操作活动进行监视,汇报磁盘活动统计情况，同时也会汇报出CPU使用情况</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-p[磁盘] 显示磁盘和分区的情况</span><br></pre></td></tr></table></figure>
</li>
<li><p>watch [参数] [命令] |重复执行某一命令以观察变化</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-n  时隔多少秒刷新</span><br><span class="line">-d  高亮显示动态变化</span><br></pre></td></tr></table></figure>
</li>
<li><p>at [参数] [时间] | 在一个指定的时间执行一个指定任务，只能执行一次</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">HH:MM[am|pm] + number [minutes|hours|days|weeks] 强制在某年某月某日的某时刻进行该项任务</span><br><span class="line">atq 查看系统未执行的任务</span><br><span class="line">atrm n 删除编号为n的任务</span><br><span class="line">at -c n 显示编号为n的任务的内容</span><br></pre></td></tr></table></figure>
</li>
<li><p>crontab | 定时任务调度</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">file    载入crontab</span><br><span class="line">    -e  编辑某个用户的crontab文件内容</span><br><span class="line">    -l  显示某个用户的crontab文件内容</span><br><span class="line">    -r  删除某个用户的crontab文件</span><br></pre></td></tr></table></figure>
</li>
<li><p>ifconfig [网络设备] [参数] | 查看和配置网络设备</p>
</li>
<li>route | 显示和操作IP路由表</li>
<li><p>ping [参数] [主机名或IP地址] | 测试与目标主机的连通性</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-q  只显示最后的结果</span><br></pre></td></tr></table></figure>
</li>
<li><p>netstat | 显示与IP、TCP、UDP和ICMP协议相关的统计数据</p>
</li>
<li>telnet [参数] [主机] | 用于远程登录，采用明文传送报文，安全性不好</li>
<li><p>rcp [参数] [源文件] [目标文件] | 远程文件拷贝</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">-r  递归复制</span><br><span class="line">-p  保留源文件的属性</span><br><span class="line">usage: rcp –r remote_hostname:remote_dir local_dir</span><br></pre></td></tr></table></figure>
</li>
<li><p>wget [参数] [URL地址] | 直接从网络上下载文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-o FILE 把记录写到FILE文件中    eg : wget -O a.txt URL</span><br><span class="line">wget --limit-rate=300k URL  限速下载</span><br></pre></td></tr></table></figure>
</li>
<li><p>awk</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-F 分隔符  以分隔符分隔内容</span><br><span class="line">&#123;&#125;  要执行的脚本内容 eg:cat /etc/passwd |awk  -F ':'  '&#123;print $1"\t"$7&#125;'</span><br></pre></td></tr></table></figure>
</li>
<li><p>sed 对数据行进行替换、删除、新增、选取等操作</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">a   新增，在新的下一行出现</span><br><span class="line">c   取代，取代 n1,n2 之间的行 eg: sed '1,2c Hi' ab</span><br><span class="line">d   删除</span><br><span class="line">i   插入，在新的上一行出现</span><br></pre></td></tr></table></figure>
</li>
<li><p>paste 合并文件，需确保合并的两文件行数相同</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-d  指定不同于空格或tab键的域分隔符</span><br><span class="line">-s  按行合并，单独一个文件为一行</span><br></pre></td></tr></table></figure>
</li>
<li><p>su [参数] user | 切换登陆</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-l  切换时连同环境变量、工作目录一起改变</span><br><span class="line">-c command  执行command变回原来的使用者</span><br></pre></td></tr></table></figure>
</li>
<li><p>sudo | 以特定用户的权限执行特定命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-l  列出当前用户可执行的命令</span><br><span class="line">-u username#uid 以指定用户执行命令</span><br></pre></td></tr></table></figure>
</li>
<li><p>file | 判断文件类型</p>
</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2018/05/31/linux/linux简单命令/" data-id="ckcc5iwpx009fq4uwe9wmxqk6" class="article-share-link">Teilen</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/">linux</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2018/05/31/ZipUtil/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Neuer</strong>
      <div class="article-nav-title">
        
          ZipUtil
        
      </div>
    </a>
  
  
    <a href="/2018/05/30/复杂度/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Älter</strong>
      <div class="article-nav-title">算法复杂度</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Design-Patterns/">Design Patterns</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/">Git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Html/">Html</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Http/">Http</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Sort/">Sort</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/algorithm/">algorithm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ali-weixin-pay/">ali/weixin pay</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/">docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/elasticsearch/">elasticsearch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/">go</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/idea/">idea</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jvm/">jvm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/logstash/">logstash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mysql/">mysql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/php/">php</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pytest/">pytest</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/springboot/">springboot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/util/">util</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vue/">vue</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wechat/">wechat</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/我的世界/">我的世界</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/消息队列/">消息队列</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/线程/">线程</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Design-Patterns/" style="font-size: 16.36px;">Design Patterns</a> <a href="/tags/Git/" style="font-size: 10px;">Git</a> <a href="/tags/Html/" style="font-size: 10px;">Html</a> <a href="/tags/Http/" style="font-size: 12.73px;">Http</a> <a href="/tags/JavaScript/" style="font-size: 15.45px;">JavaScript</a> <a href="/tags/Sort/" style="font-size: 18.18px;">Sort</a> <a href="/tags/algorithm/" style="font-size: 11.82px;">algorithm</a> <a href="/tags/ali-weixin-pay/" style="font-size: 13.64px;">ali/weixin pay</a> <a href="/tags/docker/" style="font-size: 17.27px;">docker</a> <a href="/tags/elasticsearch/" style="font-size: 10px;">elasticsearch</a> <a href="/tags/go/" style="font-size: 11.82px;">go</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/idea/" style="font-size: 10px;">idea</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/jvm/" style="font-size: 11.82px;">jvm</a> <a href="/tags/linux/" style="font-size: 18.18px;">linux</a> <a href="/tags/logstash/" style="font-size: 12.73px;">logstash</a> <a href="/tags/mysql/" style="font-size: 14.55px;">mysql</a> <a href="/tags/php/" style="font-size: 11.82px;">php</a> <a href="/tags/pytest/" style="font-size: 10px;">pytest</a> <a href="/tags/python/" style="font-size: 13.64px;">python</a> <a href="/tags/springboot/" style="font-size: 17.27px;">springboot</a> <a href="/tags/util/" style="font-size: 19.09px;">util</a> <a href="/tags/vue/" style="font-size: 10px;">vue</a> <a href="/tags/wechat/" style="font-size: 10.91px;">wechat</a> <a href="/tags/我的世界/" style="font-size: 10px;">我的世界</a> <a href="/tags/消息队列/" style="font-size: 10.91px;">消息队列</a> <a href="/tags/线程/" style="font-size: 11.82px;">线程</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archiv</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/04/">April 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/03/">March 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/01/">January 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">October 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">February 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">January 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">December 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">November 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">October 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">September 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">July 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">June 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">May 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">April 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">March 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">February 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">January 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">December 2017</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">letzter Beitrag</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/05/17/linux/linux_shell/">linux—shell</a>
          </li>
        
          <li>
            <a href="/2020/05/16/linux/linux_awk_sed/">linux-awk\sed 示例</a>
          </li>
        
          <li>
            <a href="/2020/04/11/linux/linux_bash/">linux—bash</a>
          </li>
        
          <li>
            <a href="/2020/03/29/hello-world/">Hello World</a>
          </li>
        
          <li>
            <a href="/2020/03/16/go基础/">go基础知识</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 vchen<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>